#include <iostream>
#include <set>
using namespace std;

int n,k,vis[50005] = {0};
struct item{
    int count,id;
    bool operator<(const item& i) const{
        if(count==i.count)    return id<i.id;
        return count>i.count;
    }
};
set<item> s;

signed main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(i>=1){
            cout<<a<<":";
            int cnt = 0;
            for(auto it:s){
                if(cnt>=k)    break;
                cout<<" "<<it.id;
                cnt++;
            }
            cout<<"\n";
        }
        if(!vis[a]){
            vis[a]++;
            s.insert({1,a});
        }
        else{
            s.erase(s.find({vis[a],a}));
            vis[a]++;
            s.insert({vis[a],a});
        }
    }
    return 0;
}
